package cn.edu.nuaa.aadl2.generatorC.template;

import cn.edu.nuaa.aadl2.generatorC.utils.StringUtils;
import cn.edu.nuaa.aadl2.generatorC.utils.Tools;
import com.google.common.base.Objects;
import org.eclipse.emf.common.util.EList;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.osate.aadl2.AbstractNamedValue;
import org.osate.aadl2.BasicPropertyAssociation;
import org.osate.aadl2.Classifier;
import org.osate.aadl2.Connection;
import org.osate.aadl2.DataAccess;
import org.osate.aadl2.DataPort;
import org.osate.aadl2.DirectionType;
import org.osate.aadl2.Element;
import org.osate.aadl2.EnumerationLiteral;
import org.osate.aadl2.EventDataPort;
import org.osate.aadl2.EventPort;
import org.osate.aadl2.Feature;
import org.osate.aadl2.ModalPropertyValue;
import org.osate.aadl2.Parameter;
import org.osate.aadl2.ProcessSubcomponent;
import org.osate.aadl2.PropertyAssociation;
import org.osate.aadl2.PropertyExpression;
import org.osate.aadl2.PropertyType;
import org.osate.aadl2.Subcomponent;
import org.osate.aadl2.SubprogramAccess;
import org.osate.aadl2.SystemImplementation;
import org.osate.aadl2.impl.BooleanLiteralImpl;
import org.osate.aadl2.impl.ClassifierValueImpl;
import org.osate.aadl2.impl.DataTypeImpl;
import org.osate.aadl2.impl.IntegerLiteralImpl;
import org.osate.aadl2.impl.ListValueImpl;
import org.osate.aadl2.impl.NamedValueImpl;
import org.osate.aadl2.impl.RecordValueImpl;
import org.osate.aadl2.impl.ReferenceValueImpl;
import org.osate.aadl2.impl.StringLiteralImpl;

@SuppressWarnings("all")
public class CoreXml {
  /**
   * 功能：处理每个分区的属性
   * by:qiubao
   */
  private static String a;
  
  private static BasicPropertyAssociation b;
  
  private static PropertyExpression c;
  
  private static BasicPropertyAssociation d;
  
  private static BasicPropertyAssociation e;
  
  private static PropertyExpression f;
  
  private static int g = (-1);
  
  private static int h = 0;
  
  private static String m;
  
  public static CharSequence createPropertyXml(final SystemImplementation system, final String system_folder) {
    StringConcatenation _builder = new StringConcatenation();
    Tools.createFile(system_folder, "core.xml", CoreXml.property2Xml(system).toString());
    _builder.newLineIfNotEmpty();
    return _builder;
  }
  
  public static CharSequence property2Xml(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    _builder.newLine();
    _builder.append("<ARINC_653_Module xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    _builder.newLine();
    _builder.append("xsi:noNamespaceSchemaLocation=\".\\A653_Part1_revA.xsdClearwater Version 1.1 .xsd\" ModuleName=\"IMA\" ModuleVersion=\"18-Mar-2003\">--这一段应该是模型的顶层系统");
    _builder.newLine();
    _builder.append("\t");
    CharSequence _partitionPort = CoreXml.partitionPort(system);
    _builder.append(_partitionPort, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    CharSequence _partitionMemory = CoreXml.partitionMemory(system);
    _builder.append(_partitionMemory, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    CharSequence _module_schedule = CoreXml.module_schedule(system);
    _builder.append(_module_schedule, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    CharSequence _partitionCommunicate = CoreXml.partitionCommunicate(system);
    _builder.append(_partitionCommunicate, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append("</ARINC_653_Module >");
    _builder.newLine();
    return _builder;
  }
  
  public static CharSequence partitionPort(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<Subcomponent> _allSubcomponents = system.getAllSubcomponents();
      boolean _tripleNotEquals = (_allSubcomponents != null);
      if (_tripleNotEquals) {
        {
          EList<ProcessSubcomponent> _ownedProcessSubcomponents = system.getOwnedProcessSubcomponents();
          for(final ProcessSubcomponent subcomponent : _ownedProcessSubcomponents) {
            _builder.append("<Partition  ");
            CharSequence _partitionProperty = CoreXml.partitionProperty(subcomponent);
            _builder.append(_partitionProperty);
            _builder.append(">");
            _builder.newLineIfNotEmpty();
            {
              EList<Feature> _allFeatures = subcomponent.getClassifier().getAllFeatures();
              for(final Feature feature : _allFeatures) {
                _builder.append("\t\t\t");
                CharSequence _template = CoreXml.template(feature);
                _builder.append(_template, "\t\t\t");
                _builder.newLineIfNotEmpty();
              }
            }
            _builder.append("</Partition>");
            _builder.newLine();
          }
        }
      }
    }
    return _builder;
  }
  
  public static CharSequence partitionProperty(final ProcessSubcomponent subcomponent) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<PropertyAssociation> _ownedPropertyAssociations = subcomponent.getOwnedPropertyAssociations();
      for(final PropertyAssociation property : _ownedPropertyAssociations) {
        {
          EList<ModalPropertyValue> _ownedValues = property.getOwnedValues();
          for(final ModalPropertyValue valuelist : _ownedValues) {
            PropertyExpression s = valuelist.getOwnedValue();
            _builder.newLineIfNotEmpty();
            String t = property.getProperty().getName();
            _builder.newLineIfNotEmpty();
            String _switchResult = null;
            if (t != null) {
              switch (t) {
                case "Partition_Identifier":
                  _switchResult = ((("PartitionID=" + "\"") + s) + "\"");
                  break;
                case "Partition_Name":
                  String _get = s.toString().split("\"")[1];
                  String _plus = (("PartitionName=" + "\"") + _get);
                  _switchResult = (_plus + "\"");
                  break;
              }
            }
            _builder.append(_switchResult);
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    return _builder;
  }
  
  public static CharSequence template(final Feature feature) {
    CharSequence _switchResult = null;
    boolean _matched = false;
    if (feature instanceof DataPort) {
      _matched=true;
      StringConcatenation _builder = new StringConcatenation();
      {
        boolean _equals = ((DataPort)feature).getDirection().equals(DirectionType.IN);
        if (_equals) {
          _builder.append("<Sampling_Port PortName=\"");
          String _convertNo2Low = StringUtils.convertNo2Low(((DataPort)feature).getName());
          _builder.append(_convertNo2Low);
          _builder.append("\" MaxMessageSize=\"30\" Direction=\"SOURCE\"/>");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        boolean _equals_1 = ((DataPort)feature).getDirection().equals(DirectionType.OUT);
        if (_equals_1) {
          _builder.append("<Sampling_Port PortName=\"");
          String _convertNo2Low_1 = StringUtils.convertNo2Low(((DataPort)feature).getName());
          _builder.append(_convertNo2Low_1);
          _builder.append("\" MaxMessageSize=\"30\" Direction=\"DESTINATION\"/>");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        boolean _equals_2 = ((DataPort)feature).getDirection().equals(DirectionType.IN_OUT);
        if (_equals_2) {
        }
      }
      _switchResult = _builder;
    }
    if (!_matched) {
      if (feature instanceof EventPort) {
        _matched=true;
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Unhandeled EventPort at FeatureTemplate.xtend line 76");
        _builder.newLine();
        _switchResult = _builder;
      }
    }
    if (!_matched) {
      if (feature instanceof EventDataPort) {
        _matched=true;
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("//EventDataPort");
        _builder.newLine();
        {
          boolean _equals = ((EventDataPort)feature).getDirection().equals(DirectionType.IN);
          if (_equals) {
            _builder.append("<Queuing PortName=\"");
            String _convertNo2Low = StringUtils.convertNo2Low(((EventDataPort)feature).getName());
            _builder.append(_convertNo2Low);
            _builder.append("\" MaxMessageSize=\"30\" Direction=\"SOURCE\"/>");
            _builder.newLineIfNotEmpty();
          }
        }
        {
          boolean _equals_1 = ((EventDataPort)feature).getDirection().equals(DirectionType.OUT);
          if (_equals_1) {
            _builder.append("<Queuing PortName=\"");
            String _convertNo2Low_1 = StringUtils.convertNo2Low(((EventDataPort)feature).getName());
            _builder.append(_convertNo2Low_1);
            _builder.append("\" MaxMessageSize=\"30\" Direction=\"DESTINATION\"/>");
            _builder.newLineIfNotEmpty();
          }
        }
        {
          boolean _equals_2 = ((EventDataPort)feature).getDirection().equals(DirectionType.IN_OUT);
          if (_equals_2) {
          }
        }
        _switchResult = _builder;
      }
    }
    if (!_matched) {
      if (feature instanceof Parameter) {
        _matched=true;
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("Unhandeled Patameter at FeatureTemplate.xtend line 87");
        _builder.newLine();
        _switchResult = _builder;
      }
    }
    if (!_matched) {
      if (feature instanceof SubprogramAccess) {
        _matched=true;
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("//feature subprogramaccess 通过引用对应子程序的头文件实现");
        _builder.newLine();
        _builder.append("extern void ");
        String _clearspace = StringUtils.clearspace(CoreXml.getFeatureClassifier0(feature).toString());
        _builder.append(_clearspace);
        _builder.append("(paras...);");
        _builder.newLineIfNotEmpty();
        _switchResult = _builder;
      }
    }
    if (!_matched) {
      if (feature instanceof DataAccess) {
        _matched=true;
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/* global */");
        _builder.newLine();
        _builder.append("extern ");
        String _clearspace = StringUtils.clearspace(CoreXml.getFeatureClassifier0(feature).toString());
        _builder.append(_clearspace);
        _builder.append(" ");
        String _convertNo2Low = StringUtils.convertNo2Low(((DataAccess)feature).getName());
        _builder.append(_convertNo2Low);
        _builder.append(";");
        _builder.newLineIfNotEmpty();
        {
          EList<PropertyAssociation> _ownedPropertyAssociations = ((DataAccess)feature).getOwnedPropertyAssociations();
          for(final PropertyAssociation property : _ownedPropertyAssociations) {
            String _fullName = property.getProperty().getFullName();
            _builder.append(_fullName);
            _builder.append(" : ");
            PropertyType _ownedPropertyType = property.getProperty().getOwnedPropertyType();
            _builder.append(_ownedPropertyType);
            _builder.newLineIfNotEmpty();
          }
        }
        _builder.newLine();
        _switchResult = _builder;
      }
    }
    return _switchResult;
  }
  
  /**
   * 功能：处理分区的内存分配，分为3个部分：框架，分区属性，内存分配属性
   * by:qiubao
   */
  public static CharSequence partitionMemory(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<Subcomponent> _allSubcomponents = system.getAllSubcomponents();
      boolean _tripleNotEquals = (_allSubcomponents != null);
      if (_tripleNotEquals) {
        {
          EList<ProcessSubcomponent> _ownedProcessSubcomponents = system.getOwnedProcessSubcomponents();
          for(final ProcessSubcomponent subcomponent : _ownedProcessSubcomponents) {
            _builder.append("<Partition_Memory ");
            CharSequence _partitionProperty = CoreXml.partitionProperty(subcomponent);
            _builder.append(_partitionProperty);
            _builder.append(">");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            CharSequence _partition = CoreXml.partition(subcomponent);
            _builder.append(_partition, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append("</Partition_Memory>");
            _builder.newLine();
          }
        }
      }
    }
    return _builder;
  }
  
  public static CharSequence partition(final ProcessSubcomponent subcomponent) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<PropertyAssociation> _ownedPropertyAssociations = subcomponent.getOwnedPropertyAssociations();
      for(final PropertyAssociation property : _ownedPropertyAssociations) {
        {
          EList<ModalPropertyValue> _ownedValues = property.getOwnedValues();
          for(final ModalPropertyValue valuelist : _ownedValues) {
            String t = property.getProperty().getName();
            _builder.newLineIfNotEmpty();
            PropertyExpression s = valuelist.getOwnedValue();
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t  \t");
            CharSequence _switchResult = null;
            if (t != null) {
              switch (t) {
                case "Memory_Type":
                  _switchResult = null;
                  break;
                case "Code_Size":
                  StringConcatenation _builder_1 = new StringConcatenation();
                  _builder_1.append("<Memory_Requirements Type=\"CODE\" SizeBytes=\"");
                  String _string = s.toString();
                  int _length = s.toString().length();
                  int _minus = (_length - 4);
                  String _substring = _string.substring(0, _minus);
                  _builder_1.append(_substring);
                  _builder_1.append("\" Access=\"READ_ONLY\"/>");
                  _switchResult = _builder_1;
                  break;
                case "Data_Size":
                  StringConcatenation _builder_2 = new StringConcatenation();
                  _builder_2.append("<Memory_Requirements Type=\"DATA\" SizeBytes=\"");
                  String _string_1 = s.toString();
                  int _length_1 = s.toString().length();
                  int _minus_1 = (_length_1 - 4);
                  String _substring_1 = _string_1.substring(0, _minus_1);
                  _builder_2.append(_substring_1);
                  _builder_2.append("\" Access=\"READ_WRITE\"/>");
                  _switchResult = _builder_2;
                  break;
              }
            }
            _builder.append(_switchResult, "\t\t  \t");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    return _builder;
  }
  
  /**
   * 功能：xml中的分区调度
   * by:qiubao
   */
  public static CharSequence module_schedule(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("<Module_Schedule MajorFrameSeconds=\"");
    CharSequence _module_schedule_time = CoreXml.module_schedule_time(system);
    _builder.append(_module_schedule_time);
    _builder.append("\">");
    _builder.newLineIfNotEmpty();
    _builder.append(" \t\t");
    CharSequence _module_Schedule_part2 = CoreXml.module_Schedule_part2(system.getAllPropertyAssociations().get(1));
    _builder.append(_module_Schedule_part2, " \t\t");
    _builder.newLineIfNotEmpty();
    _builder.append("</Module_Schedule>");
    _builder.newLine();
    return _builder;
  }
  
  public static CharSequence module_schedule_time(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append(CoreXml.m = system.getAllPropertyAssociations().get(0).getOwnedValues().get(0).getOwnedValue().toString().substring(0, 3));
    _builder.newLineIfNotEmpty();
    return _builder;
  }
  
  public static CharSequence module_Schedule_part2(final PropertyAssociation property) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<ModalPropertyValue> _ownedValues = property.getOwnedValues();
      for(final ModalPropertyValue value : _ownedValues) {
        PropertyExpression ownedValue = value.getOwnedValue();
        _builder.newLineIfNotEmpty();
        CharSequence _switchResult = null;
        boolean _matched = false;
        if (ownedValue instanceof NamedValueImpl) {
          _matched=true;
          StringConcatenation _builder_1 = new StringConcatenation();
          String _parseNamedValue = CoreXml.parseNamedValue(((NamedValueImpl)ownedValue).getNamedValue());
          _builder_1.append(_parseNamedValue);
          _switchResult = _builder_1;
        }
        if (!_matched) {
          if (ownedValue instanceof StringLiteralImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            String _value = ((StringLiteralImpl)ownedValue).getValue();
            String _plus = (_value + "(features...);");
            _builder_1.append(_plus);
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          if (ownedValue instanceof ListValueImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            CharSequence _parseListValue = CoreXml.parseListValue(((ListValueImpl)ownedValue));
            _builder_1.append(_parseListValue);
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          StringConcatenation _builder_1 = new StringConcatenation();
          String _string = ownedValue.toString();
          _builder_1.append(_string);
          _switchResult = _builder_1;
        }
        _builder.append(_switchResult);
        _builder.newLineIfNotEmpty();
      }
    }
    return _builder;
  }
  
  public static CharSequence module_schedule1(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<Subcomponent> _allSubcomponents = system.getAllSubcomponents();
      boolean _tripleNotEquals = (_allSubcomponents != null);
      if (_tripleNotEquals) {
        {
          EList<PropertyAssociation> _allPropertyAssociations = system.getAllPropertyAssociations();
          for(final PropertyAssociation sysProperty : _allPropertyAssociations) {
            String s = sysProperty.getProperty().getName();
            _builder.newLineIfNotEmpty();
            EList<ModalPropertyValue> t = sysProperty.getOwnedValues();
            _builder.newLineIfNotEmpty();
            CharSequence _switchResult = null;
            if (s != null) {
              switch (s) {
                case "Module_Major_Frame":
                  StringConcatenation _builder_1 = new StringConcatenation();
                  _builder_1.append("<Module_Schedule MajorFrameSeconds=\"");
                  String _substring = t.get(0).getOwnedValue().toString().substring(0, 3);
                  _builder_1.append(_substring);
                  _builder_1.append("\">");
                  _switchResult = _builder_1;
                  break;
                case "Module_Schedule":
                  _switchResult = CoreXml.moduleSchedule(sysProperty);
                  break;
              }
            }
            _builder.append(_switchResult);
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    return _builder;
  }
  
  public static CharSequence moduleSchedule(final PropertyAssociation pa) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<ModalPropertyValue> _ownedValues = pa.getOwnedValues();
      for(final ModalPropertyValue list2 : _ownedValues) {
        _builder.append("\t\t--pa的属性");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        PropertyExpression list3 = list2.getOwnedValue();
        _builder.append("--这里拿到的是Module_Schedule两个元素");
        _builder.newLineIfNotEmpty();
        {
          EList<Element> _ownedElements = list3.getOwnedElements();
          for(final Element list4 : _ownedElements) {
            _builder.append("\t\t");
            {
              EList<Element> _ownedElements_1 = list4.getOwnedElements();
              for(final Element value : _ownedElements_1) {
                _builder.append("\t--这里应该拿每项里的3个元素");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("\t\t");
                String _println = InputOutput.<String>println(value.toString());
                _builder.append(_println, "\t\t\t\t");
                _builder.newLineIfNotEmpty();
              }
            }
          }
        }
      }
    }
    _builder.append("<Partition_Schedule PartitionName=\"partition1\" PeriodSeconds=\"");
    _builder.append(CoreXml.m);
    _builder.append("\" PeriodDurationSeconds=\"");
    _builder.append("\">");
    _builder.newLineIfNotEmpty();
    _builder.append("   \t    ");
    _builder.append("<Window_Schedule WindowIdentifier=\"101\" WindowStartSeconds=\"0.0\" WindowDurationSeconds=\"0.040\"/>");
    _builder.newLine();
    _builder.append("  \t");
    _builder.append("</Partition_Schedule>");
    _builder.newLine();
    return _builder;
  }
  
  /**
   * 功能：分区间通信channel：下面的分区间通信，以后要考虑subprogram的
   * by:邱宝
   */
  public static CharSequence partitionCommunicate(final SystemImplementation system) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.newLine();
    {
      EList<Connection> _allConnections = system.getAllConnections();
      boolean _tripleNotEquals = (_allConnections != null);
      if (_tripleNotEquals) {
        {
          EList<Connection> _ownedConnections = system.getOwnedConnections();
          for(final Connection connection : _ownedConnections) {
            {
              EList<PropertyAssociation> _ownedPropertyAssociations = connection.getOwnedPropertyAssociations();
              for(final PropertyAssociation connectProperty : _ownedPropertyAssociations) {
                {
                  boolean _notEquals = (!Objects.equal(connectProperty, null));
                  if (_notEquals) {
                    _builder.append("<Channel ChannelID=\"");
                    PropertyExpression _ownedValue = connectProperty.getOwnedValues().get(0).getOwnedValue();
                    _builder.append(_ownedValue);
                    _builder.append("\" ChannelName=\"");
                    String _name = connection.getName();
                    _builder.append(_name);
                    _builder.append(" \">");
                    _builder.newLineIfNotEmpty();
                    _builder.append("   ");
                    _builder.append("<Source>");
                    _builder.newLine();
                    _builder.append("      ");
                    _builder.append("<Partition PartitionName=\"");
                    String _name_1 = connection.getSource().getContext().getName();
                    _builder.append(_name_1, "      ");
                    _builder.append("\" PortName=\"");
                    String _name_2 = connection.getSource().getConnectionEnd().getName();
                    _builder.append(_name_2, "      ");
                    _builder.append(" \"/>");
                    _builder.newLineIfNotEmpty();
                    _builder.append("   ");
                    _builder.append("</Source>");
                    _builder.newLine();
                    _builder.append("   ");
                    _builder.append("<Destination>");
                    _builder.newLine();
                    _builder.append("      ");
                    _builder.append("<Partition PartitionName=\"");
                    String _name_3 = connection.getDestination().getContext().getName();
                    _builder.append(_name_3, "      ");
                    _builder.append(" \" PortName=\"");
                    String _name_4 = connection.getDestination().getConnectionEnd().getName();
                    _builder.append(_name_4, "      ");
                    _builder.append(" \"/>");
                    _builder.newLineIfNotEmpty();
                    _builder.append("   ");
                    _builder.append("</Destination>");
                    _builder.newLine();
                  }
                }
                _builder.append("<Destination>");
                _builder.newLine();
                _builder.append("   ");
                _builder.append("<Partition PartitionName=\"");
                String _name_5 = connection.getDestination().getContext().getName();
                _builder.append(_name_5, "   ");
                _builder.append(" \" PortName=\"");
                String _name_6 = connection.getDestination().getConnectionEnd().getName();
                _builder.append(_name_6, "   ");
                _builder.append(" \"/>");
                _builder.newLineIfNotEmpty();
                _builder.append("</Destination>");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("</Channel>");
                _builder.newLine();
              }
            }
          }
        }
      }
    }
    _builder.append("   ");
    _builder.newLine();
    return _builder;
  }
  
  public static String parseNamedValue(final AbstractNamedValue value) {
    boolean _matched = false;
    if (value instanceof EnumerationLiteral) {
      _matched=true;
      return ((EnumerationLiteral)value).getName();
    }
    if (!_matched) {
      if (value instanceof RecordValueImpl) {
        _matched=true;
        return value.toString();
      }
    }
    return value.getClass().getName();
  }
  
  /**
   * 当前针对StringLiteralImpl的处理,在每个property的property.ownedValues的for循环中不断解析 ListValueImpl
   */
  public static CharSequence parseListValue(final ListValueImpl value) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<PropertyExpression> _ownedListElements = value.getOwnedListElements();
      for(final PropertyExpression expression : _ownedListElements) {
        CharSequence _switchResult = null;
        boolean _matched = false;
        if (expression instanceof StringLiteralImpl) {
          _matched=true;
          StringConcatenation _builder_1 = new StringConcatenation();
          String _value = ((StringLiteralImpl)expression).getValue();
          _builder_1.append(_value);
          _switchResult = _builder_1;
        }
        if (!_matched) {
          if (expression instanceof NamedValueImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            String _parseNamedValue = CoreXml.parseNamedValue(((NamedValueImpl)expression).getNamedValue());
            _builder_1.append(_parseNamedValue);
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          if (expression instanceof ClassifierValueImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            String _parseClassifier = CoreXml.parseClassifier(((ClassifierValueImpl)expression).getClassifier());
            _builder_1.append(_parseClassifier);
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          if (expression instanceof IntegerLiteralImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append(((IntegerLiteralImpl)expression));
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          if (expression instanceof RecordValueImpl) {
            _matched=true;
            StringConcatenation _builder_1 = new StringConcatenation();
            CharSequence _recordValueImpl = CoreXml.recordValueImpl(((RecordValueImpl)expression));
            _builder_1.append(_recordValueImpl);
            _switchResult = _builder_1;
          }
        }
        if (!_matched) {
          StringConcatenation _builder_1 = new StringConcatenation();
          String _string = expression.toString();
          _builder_1.append(_string);
          _switchResult = _builder_1;
        }
        _builder.append(_switchResult);
        _builder.newLineIfNotEmpty();
      }
    }
    return _builder;
  }
  
  public static CharSequence recordValueImpl(final RecordValueImpl recordlist) {
    CharSequence _xblockexpression = null;
    {
      EList<BasicPropertyAssociation> _ownedFieldValues = recordlist.getOwnedFieldValues();
      for (final BasicPropertyAssociation record : _ownedFieldValues) {
        PropertyExpression _ownedValue = record.getOwnedValue();
        boolean _matched = false;
        if (_ownedValue instanceof StringLiteralImpl) {
          _matched=true;
          record.getValue();
        }
        if (!_matched) {
          if (_ownedValue instanceof NamedValueImpl) {
            _matched=true;
            record.getOwnedValue();
          }
        }
        if (!_matched) {
          if (_ownedValue instanceof ClassifierValueImpl) {
            _matched=true;
            CoreXml.d = record;
          }
        }
        if (!_matched) {
          if (_ownedValue instanceof IntegerLiteralImpl) {
            _matched=true;
            CoreXml.c = record.getValue();
          }
        }
        if (!_matched) {
          if (_ownedValue instanceof RecordValueImpl) {
            _matched=true;
            CoreXml.e = record;
          }
        }
        if (!_matched) {
          if (_ownedValue instanceof ReferenceValueImpl) {
            _matched=true;
            CoreXml.a = record.getProperty().getName();
          }
        }
        if (!_matched) {
          if (_ownedValue instanceof BooleanLiteralImpl) {
            _matched=true;
            record.getValue();
          }
        }
        if (!_matched) {
          record.toString();
        }
      }
      CoreXml.g = (CoreXml.g + 1);
      _xblockexpression = CoreXml.recordValueImpl1(recordlist);
    }
    return _xblockexpression;
  }
  
  public static CharSequence recordValueImpl1(final RecordValueImpl recordlist) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("<Partition_Schedule PartitionName=\"");
    _builder.append(CoreXml.a);
    _builder.append("\" PeriodSeconds=\"");
    _builder.append(CoreXml.m);
    _builder.append("\" PeriodDurationSeconds=\"");
    String _substring = CoreXml.c.toString().substring(0, 3);
    _builder.append(_substring);
    _builder.append("\">");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("<Window_Schedule WindowIdentifier=\"");
    _builder.append((101 + CoreXml.g), "\t");
    _builder.append("\" WindowStartSeconds=\"");
    _builder.append(CoreXml.a, "\t");
    _builder.append("\" WindowDurationSeconds=\"");
    String _substring_1 = CoreXml.c.toString().substring(0, 3);
    _builder.append(_substring_1, "\t");
    _builder.append("\"/>");
    _builder.newLineIfNotEmpty();
    _builder.append("</Partition_Schedule>");
    _builder.newLine();
    return _builder;
  }
  
  public static String parseClassifier(final Classifier classifier) {
    Classifier clazz = classifier;
    try {
      String type = ((DataTypeImpl) clazz).getName();
      return type;
    } catch (final Throwable _t) {
      if (_t instanceof Exception) {
        final Exception exception = (Exception)_t;
        return "Classifier can\'t be cast to DataTypeImpl . fdafds in PropertyTemplate.xtend !! \n";
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
  
  public static String getFeatureClassifier0(final Feature feature) {
    Classifier _classifier = feature.getClassifier();
    boolean _tripleNotEquals = (_classifier != null);
    if (_tripleNotEquals) {
      String f = StringUtils.convertNo2Low(feature.getClassifier().getName());
      if (f != null) {
        switch (f) {
          case "Integer":
            return "int";
          default:
            return f;
        }
      } else {
        return f;
      }
    } else {
      String _name = feature.getName();
      return (_name + "\'s classifier is null. error in FeatureTemplate line 58");
    }
  }
}
